package com.hlkj.baojin.utils.bean;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * http请求返回处理工具类
 * @author  lzx
 * @date 19:25 2018-07-23
 */
public class JsonResult<T>{
    /**
     *  状态码
     */
    private Integer statusCode;
    /**
     *  返回说明
     */
    private String resultMsg;



    /**
     * 具体的内容数据.
     */
    private T resultData;

    public static <T> JsonResult<T> success(T o){        //Object object
        JsonResult<T> result = new JsonResult<T>();
        result.setStatusCode(200);
        result.setResultMsg("请求正常");
        result.setResultData(o);
        return result;
    }


    public static JsonResult success(){
        JsonResult result = new JsonResult();
        result.setStatusCode(200);
        result.setResultMsg("请求正常");
        return result;
    }


    public static JsonResult error(Integer code, String msg){
        JsonResult result = new JsonResult();
        result.setStatusCode(code);
        result.setResultMsg(msg);
        return result;
    }






    public T getResultData() {
        return resultData;
    }

    public void setResultData(T resultData) {
        this.resultData = resultData;
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Integer statusCode) {
        this.statusCode = statusCode;
    }

    public String getResultMsg() {
        return resultMsg;
    }

    public void setResultMsg(String resultMsg) {
        this.resultMsg = resultMsg;
    }

    @Override
    public String toString() {
        return "JsonResult{" +
                "statusCode=" + statusCode +
                ", resultMsg='" + resultMsg + '\'' +
                ", resultData=" + resultData +
                '}';
    }
}